package org.gdstash.db;

import org.gdstash.util.GDColor;

import java.awt.*;

public class ItemClass {
    public static int getRarityInt(final String rarity) {
        if (rarity == null) {
            return -1;
        }
        if (rarity.equals("Broken")) {
            return 1;
        }
        if (rarity.equals("Common")) {
            return 2;
        }
        if (rarity.equals("Magical")) {
            return 3;
        }
        if (rarity.equals("Rare")) {
            return 4;
        }
        if (rarity.equals("Epic")) {
            return 5;
        }
        if (rarity.equals("Legendary")) {
            return 6;
        }
        if (rarity.equals("Rare")) {
            return 7;
        }
        return -1;
    }

    public static int getClassInt(final String itemClass) {
        if (itemClass == null) {
            return -1;
        }
        if (itemClass.equals("ArmorProtective_Head")) {
            return 101;
        }
        if (itemClass.equals("ArmorProtective_Shoulders")) {
            return 102;
        }
        if (itemClass.equals("ArmorProtective_Chest")) {
            return 103;
        }
        if (itemClass.equals("ArmorProtective_Hands")) {
            return 104;
        }
        if (itemClass.equals("ArmorProtective_Waist")) {
            return 105;
        }
        if (itemClass.equals("ArmorProtective_Legs")) {
            return 106;
        }
        if (itemClass.equals("ArmorProtective_Feet")) {
            return 107;
        }
        if (itemClass.equals("ArmorJewelry_Amulet")) {
            return 201;
        }
        if (itemClass.equals("ArmorJewelry_Medal")) {
            return 202;
        }
        if (itemClass.equals("ArmorJewelry_Ring")) {
            return 203;
        }
        if (itemClass.equals("WeaponArmor_Offhand")) {
            return 301;
        }
        if (itemClass.equals("WeaponArmor_Shield")) {
            return 311;
        }
        if (itemClass.equals("WeaponMelee_Axe")) {
            return 321;
        }
        if (itemClass.equals("WeaponMelee_Mace")) {
            return 322;
        }
        if (itemClass.equals("WeaponHunting_Spear")) {
            return 323;
        }
        if (itemClass.equals("WeaponMelee_Sword")) {
            return 324;
        }
        if (itemClass.equals("WeaponMelee_Dagger")) {
            return 331;
        }
        if (itemClass.equals("WeaponMelee_Scepter")) {
            return 332;
        }
        if (itemClass.equals("WeaponHunting_Ranged1h")) {
            return 341;
        }
        if (itemClass.equals("WeaponMelee_Axe2h")) {
            return 351;
        }
        if (itemClass.equals("WeaponMelee_Mace2h")) {
            return 352;
        }
        if (itemClass.equals("WeaponMelee_Spear2h")) {
            return 353;
        }
        if (itemClass.equals("WeaponMagical_Staff")) {
            return 354;
        }
        if (itemClass.equals("WeaponMelee_Sword2h")) {
            return 355;
        }
        if (itemClass.equals("WeaponHunting_Ranged2h")) {
            return 361;
        }
        if (itemClass.equals("ItemArtifact")) {
            return 401;
        }
        if (itemClass.equals("ItemRelic")) {
            return 501;
        }
        if (itemClass.equals("ItemArtifactFormula")) {
            return 601;
        }
        if (itemClass.equals("QuestItem")) {
            return 701;
        }
        if (itemClass.equals("ItemDifficultyUnlock")) {
            return 702;
        }
        if (itemClass.equals("ItemFactionBooster")) {
            return 703;
        }
        if (itemClass.equals("ItemFactionWarrant")) {
            return 704;
        }
        if (itemClass.equals("ItemTransmuter")) {
            return 705;
        }
        if (itemClass.equals("OneShot_PotionHealth")) {
            return 801;
        }
        if (itemClass.equals("OneShot_PotionMana")) {
            return 802;
        }
        if (itemClass.equals("ItemUsableSkill")) {
            return 803;
        }
        if (itemClass.equals("OneShot_Scroll")) {
            return 804;
        }
        if (itemClass.equals("OneShot_Potion")) {
            return 804;
        }
        if (itemClass.equals("ItemNote")) {
            return 901;
        }
        return -1;
    }

    public static int getTransmuteType(final String itemClass) {
        if (itemClass.equals("ArmorProtective_Head")) {
            return 1;
        }
        if (itemClass.equals("ArmorProtective_Shoulders")) {
            return 14;
        }
        if (itemClass.equals("ArmorProtective_Chest")) {
            return 3;
        }
        if (itemClass.equals("ArmorProtective_Hands")) {
            return 7;
        }
        if (itemClass.equals("ArmorProtective_Legs")) {
            return 4;
        }
        if (itemClass.equals("ArmorProtective_Feet")) {
            return 5;
        }
        if (itemClass.equals("ArmorJewelry_Medal")) {
            return 15;
        }
        if (itemClass.equals("WeaponArmor_Offhand")) {
            return 8;
        }
        if (itemClass.equals("WeaponArmor_Shield")) {
            return 8;
        }
        if (itemClass.equals("WeaponMelee_Axe")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Mace")) {
            return 9;
        }
        if (itemClass.equals("WeaponHunting_Spear")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Sword")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Dagger")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Scepter")) {
            return 9;
        }
        if (itemClass.equals("WeaponHunting_Ranged1h")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Axe2h")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Mace2h")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Spear2h")) {
            return 9;
        }
        if (itemClass.equals("WeaponMagical_Staff")) {
            return 9;
        }
        if (itemClass.equals("WeaponMelee_Sword2h")) {
            return 9;
        }
        if (itemClass.equals("WeaponHunting_Ranged2h")) {
            return 9;
        }
        return -1;
    }

    public static boolean isArmor(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 100 && i < 200;
    }

    public static boolean isArtifact(final String itemClass) {
        return itemClass != null && itemClass.equals("ItemArtifact");
    }

    public static boolean isComponent(final String itemClass) {
        return itemClass != null && itemClass.equals("ItemRelic");
    }

    public static boolean isEnchantment(final String itemClass) {
        return itemClass != null && itemClass.equals("ItemEnchantment");
    }

    public static boolean isJewelry(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 200 && i < 300;
    }

    public static boolean isNote(final String itemClass) {
        return itemClass != null && itemClass.equals("ItemNote");
    }

    public static boolean isFactionBooster(final String itemClass) {
        return itemClass != null && (itemClass.equals("ItemFactionBooster") || itemClass.equals("ItemFactionWarrant") || itemClass.equals("ItemDifficultyUnlock"));
    }

    public static boolean isElixir(final String itemClass) {
        return itemClass != null && (itemClass.equals("OneShot_Scroll") || itemClass.equals("OneShot_Potion") || itemClass.equals("ItemUsableSkill"));
    }

    public static boolean isPotion(final String itemClass) {
        return itemClass != null && (itemClass.equals("OneShot_PotionHealth") || itemClass.equals("OneShot_PotionMana") || itemClass.equals("ItemDevotionReset") || itemClass.equals("ItemAttributeReset"));
    }

    public static boolean isOffhand(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 300 && i < 320;
    }

    public static boolean isWeapon(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 300 && i < 400;
    }

    public static boolean is1HWeapon(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 320 && i < 350;
    }

    public static boolean is2HWeapon(final String itemClass) {
        final int i = getClassInt(itemClass);
        return i >= 350 && i < 400;
    }

    public static boolean hasSlots(final String itemClass) {
        return itemClass != null && (itemClass.equals("ItemRelic") || itemClass.equals("ItemEnchantment"));
    }

    public static boolean hasRarity(final String itemClass) {
        return itemClass != null && (itemClass.equals("ArmorProtective_Head") || itemClass.equals("ArmorProtective_Shoulders") || itemClass.equals("ArmorProtective_Chest") || itemClass.equals("ArmorProtective_Hands") || itemClass.equals("ArmorProtective_Waist") || itemClass.equals("ArmorProtective_Legs") || itemClass.equals("ArmorProtective_Feet") || itemClass.equals("ArmorJewelry_Amulet") || itemClass.equals("ArmorJewelry_Ring") || itemClass.equals("ArmorJewelry_Medal") || itemClass.equals("WeaponMelee_Axe") || itemClass.equals("WeaponMelee_Dagger") || itemClass.equals("WeaponMelee_Mace") || itemClass.equals("WeaponHunting_Ranged1h") || itemClass.equals("WeaponMelee_Scepter") || itemClass.equals("WeaponHunting_Spear") || itemClass.equals("WeaponMelee_Sword") || itemClass.equals("WeaponMelee_Axe2h") || itemClass.equals("WeaponMelee_Mace2h") || itemClass.equals("WeaponHunting_Ranged2h") || itemClass.equals("WeaponMelee_Spear2h") || itemClass.equals("WeaponMagical_Staff") || itemClass.equals("WeaponMelee_Sword2h") || itemClass.equals("WeaponArmor_Shield") || itemClass.equals("WeaponArmor_Offhand") || itemClass.equals("ItemArtifactFormula") || itemClass.equals("ItemRelic") || itemClass.equals("ItemEnchantment") || itemClass.equals("ItemFactionBooster") || itemClass.equals("OneShot_Scroll"));
    }

    public static boolean isStackable(final String itemClass) {
        return itemClass != null && (itemClass.equals("ItemRelic") || itemClass.equals("ItemEnchantment") || itemClass.equals("OneShot_PotionHealth") || itemClass.equals("OneShot_PotionMana") || itemClass.equals("ItemDevotionReset") || itemClass.equals("ItemAttributeReset") || itemClass.equals("QuestItem") || itemClass.equals("OneShot_Scroll") || itemClass.equals("OneShot_Potion") || itemClass.equals("ItemArtifactFormula") || itemClass.equals("ItemFactionBooster") || itemClass.equals("ItemFactionWarrant") || itemClass.equals("ItemNote") || itemClass.equals("ItemUsableSkill"));
    }

    public static int getDefaultStackSize(final String itemClass) {
        if (itemClass == null) {
            return 1;
        }
        if (itemClass.equals("ItemRelic")) {
            return 100;
        }
        if (itemClass.equals("ItemEnchantment")) {
            return 100;
        }
        if (itemClass.equals("OneShot_PotionHealth")) {
            return 100;
        }
        if (itemClass.equals("OneShot_PotionMana")) {
            return 100;
        }
        if (itemClass.equals("ItemDevotionReset")) {
            return 100;
        }
        if (itemClass.equals("ItemAttributeReset")) {
            return 100;
        }
        if (itemClass.equals("QuestItem")) {
            return 1;
        }
        if (itemClass.equals("OneShot_Scroll")) {
            return 100;
        }
        if (itemClass.equals("OneShot_Potion")) {
            return 100;
        }
        if (itemClass.equals("ItemEnchantment")) {
            return 100;
        }
        if (itemClass.equals("ItemArtifactFormula")) {
            return 100;
        }
        if (itemClass.equals("ItemFactionBooster")) {
            return 100;
        }
        if (itemClass.equals("ItemFactionWarrant")) {
            return 100;
        }
        if (itemClass.equals("ItemNote")) {
            return 100;
        }
        if (itemClass.equals("ItemUsableSkill")) {
            return 100;
        }
        return 1;
    }

    public static boolean usesAffixes(final String itemClass) {
        return itemClass != null && (itemClass.equals("ArmorProtective_Head") || itemClass.equals("ArmorProtective_Shoulders") || itemClass.equals("ArmorProtective_Chest") || itemClass.equals("ArmorProtective_Hands") || itemClass.equals("ArmorProtective_Waist") || itemClass.equals("ArmorProtective_Legs") || itemClass.equals("ArmorProtective_Feet") || itemClass.equals("ArmorJewelry_Amulet") || itemClass.equals("ArmorJewelry_Ring") || itemClass.equals("ArmorJewelry_Medal") || itemClass.equals("WeaponMelee_Axe") || itemClass.equals("WeaponMelee_Dagger") || itemClass.equals("WeaponMelee_Mace") || itemClass.equals("WeaponHunting_Ranged1h") || itemClass.equals("WeaponMelee_Scepter") || itemClass.equals("WeaponHunting_Spear") || itemClass.equals("WeaponMelee_Sword") || itemClass.equals("WeaponMelee_Axe2h") || itemClass.equals("WeaponMelee_Mace2h") || itemClass.equals("WeaponHunting_Ranged2h") || itemClass.equals("WeaponMelee_Spear2h") || itemClass.equals("WeaponMagical_Staff") || itemClass.equals("WeaponMelee_Sword2h") || itemClass.equals("WeaponArmor_Shield") || itemClass.equals("WeaponArmor_Offhand"));
    }

    public static boolean usesCostFormula(final String itemClass) {
        return itemClass != null && (itemClass.equals("ArmorProtective_Head") || itemClass.equals("ArmorProtective_Shoulders") || itemClass.equals("ArmorProtective_Chest") || itemClass.equals("ArmorProtective_Hands") || itemClass.equals("ArmorProtective_Legs") || itemClass.equals("ArmorProtective_Feet") || itemClass.equals("ArmorProtective_Waist") || itemClass.equals("ArmorJewelry_Amulet") || itemClass.equals("ArmorJewelry_Medal") || itemClass.equals("ArmorJewelry_Ring") || itemClass.equals("WeaponArmor_Offhand") || itemClass.equals("WeaponArmor_Shield") || itemClass.equals("WeaponMelee_Axe") || itemClass.equals("WeaponMelee_Mace") || itemClass.equals("WeaponHunting_Spear") || itemClass.equals("WeaponMelee_Sword") || itemClass.equals("WeaponMelee_Dagger") || itemClass.equals("WeaponMelee_Scepter") || itemClass.equals("WeaponHunting_Ranged1h") || itemClass.equals("WeaponMelee_Axe2h") || itemClass.equals("WeaponMelee_Mace2h") || itemClass.equals("WeaponMelee_Spear2h") || itemClass.equals("WeaponMagical_Staff") || itemClass.equals("WeaponMelee_Sword2h") || itemClass.equals("WeaponHunting_Ranged2h"));
    }

    public static Color getRarityColor(final String rarity) {
        Color color = GDColor.COLOR_FG_COMMON;
        if (rarity != null) {
            if (rarity.equals("Magical")) {
                color = GDColor.COLOR_FG_MAGICAL;
            }
            if (rarity.equals("Rare")) {
                color = GDColor.COLOR_FG_RARE;
            }
            if (rarity.equals("Epic")) {
                color = GDColor.COLOR_FG_EPIC;
            }
            if (rarity.equals("Legendary")) {
                color = GDColor.COLOR_FG_LEGENDARY;
            }
        }
        return color;
    }

    public static Color getRarityBackgroundColor(final String rarity) {
        Color color = GDColor.COLOR_BG_COMMON;
        if (rarity != null) {
            if (rarity.equals("Magical")) {
                color = GDColor.COLOR_BG_MAGICAL;
            }
            if (rarity.equals("Rare")) {
                color = GDColor.COLOR_BG_RARE;
            }
            if (rarity.equals("Epic")) {
                color = GDColor.COLOR_BG_EPIC;
            }
            if (rarity.equals("Legendary")) {
                color = GDColor.COLOR_BG_LEGENDARY;
            }
        }
        return color;
    }
}
